package _org;

import java.util.ArrayList;


import w3c.Element;

public class DagElement implements Element{

	// composite pattern
	public ArrayList<DagElement> childs = new ArrayList<DagElement>();
	public DagElement addChild(DagElement e) {
		childs.add(e);
		return e;
	}
	
	// class vars && konstruktor
	private String kind= "";
	private String tag = "";
	private String content = "";
	public int id;
	private String buffer;
	
	public DagElement(int id, String kind, String tag, String content) {
		this.id = id;
		this.content = content;
		this.tag = tag;
		this.kind = kind;
	}
	
	@Override
	public String toString() {
		String s = "\n"+kind+", "+id+", "+tag+", "+getContent()+" .";
		for(DagElement e : childs){
			// downside propagation
			String child_str = e.toString();
			child_str = child_str.replaceAll("\n", "\n\t");
			s+=child_str;
		}
		return s;
	}
	
	// interface implementation
	public String getKind() {
		return kind;
	}

	public String getTag() {
		return tag;
	}

	public String getContent() {
		return content;
	}

	public String getBuffer() {
		return this.buffer;
	}

	public void setBuffer(String buffer) {
		this.buffer = buffer;	
	}

	
}
